package com.springcloud.frontend.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.springcloud.frontend.domain.User;

@RestController
public class HelloController {

	@Value("${server.port}")
	String port;
	
	@RequestMapping("/hello4")
	public String hello4() {
		return "<p>Hello Andrew</p>";
	}

	@RequestMapping("/hello")
	public String home() {
		System.out.println("into");
		return "hi "  + ",i am from port:" + port;
	}

	@RequestMapping("/test")
	public User hello(@RequestParam int id) {
		System.out.println("into");
		return new User(id, "emin");
	}

	@RequestMapping(value = "/hello1", method = RequestMethod.GET)
	public String hello1(@RequestParam String name) {
		return "Hello" + name;
	}

	@RequestMapping(value = "/hello2", method = RequestMethod.GET)
	public User hello(@RequestHeader String name, @RequestHeader Integer id) {
		return new User(id, name);
	}

	@RequestMapping(value = "/hello3", method = RequestMethod.POST)
	public String hello(@RequestBody User user) {
		return "Hello" + user.getName() + "," + user.getId();
	}
	
	
	
	@RequestMapping(value = "/test4", method = RequestMethod.GET)
	public String test4(){
		return "index";
	}

}
